import 'package:flutter/material.dart';
import 'package:flutter_demo/route/RouteWrapper.dart';
import '../route_widget/FirstPage.dart';
import '../route_widget/SecondPage.dart';
class  Route_Widget extends StatelessWidget {
  const  Route_Widget ({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return  MaterialApp(
      debugShowCheckedModeBanner: false,
      initialRoute: '/', // 默认界面
      // 当页面跳转时进行参数处理
      onGenerateRoute:onGenerateRoute,
      home: Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.black45,
          title:Text("路由跳转练习"),
        ),
        body: ListView(
          children: <Widget>[
            RaisedButton(
              onPressed: ()=>{
                // Navigator.push(context, MaterialPageRoute(builder: (context)=>FirstPage()))
                Navigator.of(context).push(MaterialPageRoute(builder: (context)=>FirstPage()))
              },
              child: Text("基础的路由跳转"),
            ),
            RaisedButton(
              onPressed: ()=>{
                Navigator.of(context).push(MaterialPageRoute(
                    builder: (context)=>SecondPage(content: "路由跳转并传参以及返回收参")))
                    .then((value) => print(value))
              },
              child: Text("路由跳转并传参以及返回收参"),
            ),
            RaisedButton(
              onPressed: ()=>{
                Navigator.pushNamed(context, '/third',arguments:{"content":"3传参思密达"})
              },
              child: Text("路由封装跳转"),
            ),
            RaisedButton(
              onPressed: ()=>{
                Navigator.pushNamed(context, '/fourth',arguments:{"content":"多级路由跳转方法"})
              },
              child: Text("多级路由跳转方法"),
            ),
          ],
        ),
      ),
    );
  }
}

